<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>
<form name="form1" id="form1" action="${systemctx}/sample/saveSample.web" method="post">
	<div class="pageMain">
		<div class="pageTitle">
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.bascsetting.title")%>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.channle") %>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.channle.title") %>
		</div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i><label>开始时间</label>
						<span><input type="text" value="${startTime}" name="startTime" id="startTime" class="validate[required]"></span>
					</li>
					<li>
						<i></i><label>结束时间</label>
						<span><input type="text" value="${endTime}" name="endTime" id="endTime" class="validate[required]"></span>
					</li>
				</ul>
				<ul>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request, "systemmanage.channle.column.name")%>
						</label>
						<span><input type="text" id="name" name="name"/></span> 
					</li>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.column.code")%>
						</label>
						<span><input type="text" id="code" name="code"/></span> 
					</li>
				</ul>
				<ul>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request, "systemmanage.channle.column.unit")%>
						</label>
						<span><input type="text" id="unit" name="unit"/></span> 
					</li>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request, "systemmanage.channle.column.createUserName")%>
						</label>
						<span><input type="text" id="createUserName" name="createUserName"/></span> 
					</li>
				</ul>
			</div>	
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butQuery" name="butQuery" value="<%=MessageResourcesUtils.getMessage(request, "common.button.query") %>" />
			<input type="button" class="btn btn-default" onclick="toAddChannel()" value="<%=MessageResourcesUtils.getMessage(request,"common.button.add")%>" />
		</div>
		<table>
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
<script type="text/javascript">
	$(document).ready(function(){	
		$("#startTime").date_input();
		$("#endTime").date_input();
		$('#datagrid').issdatagrid({
			formid : 'form1',
			title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.title")%>',
			width : 'auto',
			nowrap : true,
			autoRowHeight : false,
			singleSelect : true,
			striped : true,
			url : '${systemctx}/systemmanage/channel/queryChannelListInfoDataGrid.json',
			sortName: '',
			sortOrder: '',
			remoteSort : true,
			idField : 'id',
			pagination : true,
			rownumbers : true,
			showFooter : true,
			queryParams:$('#form1').serializeObject(),
			columns : [[ 
				{
					field : 'id',
					title : '<%=MessageResourcesUtils.getMessage(request, "common.button.operation") %>',
					width : 90,
					align : 'center',
					formatter : operate
				},
				{field : 'channelid',hidden : true},
			  	{title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.column.code")%>',field : 'code',sortable : true,align : 'left',width:80},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.column.name")%>',field : 'name',sortable : true,align : 'left',width:120},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.column.goodsName")%>',field : 'goodsname',sortable : true,align : 'left',width:150},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.column.costPrice")%>',field : 'costprice',sortable : true,align : 'right',width:110},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.column.preferentialPrice")%>',field : 'preferentialprice',sortable : true,width : 110,align : 'right'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.column.unit")%>',field : 'unit',sortable : true,width : 70,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.column.createTime")%>',field : 'createtime',sortable : true,width : 150,align : 'left'},
	            {title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.channle.column.createUserName")%>',field : 'createusername',sortable : true,width : 90,align : 'left'}
	        ]],
			onLoadSuccess : function(data) {

			}
		});		
		$('#butQuery').click(function() {
			$('#datagrid').datagrid('load',$('#form1').serializeObject());
		});	
		
		function operate(val, row) {
			var update = "<%=MessageResourcesUtils.getMessage(request, "common.button.update") %>";
			var del = "<%=MessageResourcesUtils.getMessage(request, "common.button.delete") %>";
			var channelid = row.channelid;
			return "<a href=\"javascript:void(0);\" class=\"easyui-linkbutton\" onclick=\"channelModify('"+val+"')\">"+update+"</a>"+
			"<a href=\"javascript:void(0);\" class=\"easyui-linkbutton\" onclick=\"channelDelete('"+channelid+"')\">"+del+"</a>";
		}

	});
	function toAddChannel(){
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/systemmanage/channel/toAddChannel.web"
		});
	}
	function channelModify(val){
		$(this).isswindow({
			noheader : true,
			url : '${systemctx}/systemmanage/channel/toUpdateChannel.web?id='+val
		});
	}
	
	function channelDelete(val) {
		var channelid = val;
		if (confirm("<%=MessageResourcesUtils.getMessage(request, "systemmanage.channle.alert4") %>")) {
			//正在执行...
			showSending();
			$.ajax({
				type : 'GET',
				url : '${systemctx}/systemmanage/channel/deleteChannel.json?channelid=' + channelid,
				dataType : 'json',
				success : function(data) {
					//关闭执行...
					closeSending();
					//显示AJAX请求后的提示信息
					$.fn.ajaxmessage(data);
					$('#datagrid').datagrid('reload',$('#form1').serializeObject());
				}
			});
		}
	}
</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>